<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
    <h:head>
        <f:metadata>
            <f:viewParam name="patientID" value="#{patientBean.patientID}"/>
            <f:event type="preRenderView" listener="#{patientBean.getPatientDetail}"/>
        </f:metadata>   
    </h:head>
    <h:body>
        <ui:composition template="template/masterlayout.xhtml">                
            <ui:define name="pagetitle">
                Edit Patient #{patientBean.patientName}
            </ui:define>
            <ui:define name="breadcrumb">
                <h:link value="Dashboard" outcome="index"/> &raquo; <h:link value="Patients management" outcome="patients"/> &raquo; <h:outputText value="Edit : #{patientBean.patientName}"/>
            </ui:define>
            <ui:define name="content">
                <h:form styleClass="jNice">
                    <fieldset>
                        <p>                            
                            <h:outputLabel for="patientName">Patient Name: </h:outputLabel>
                            <h:inputText id="patientName" value="#{patientBean.patientName}" required="true" requiredMessage="#{msgs.Patient_NameRequire}" validatorMessage="#{msgs.Patient_NameLeght}">
                                <f:validateLength minimum="3" maximum="30"/>
                            </h:inputText>
                            <h:message for="patientName" styleClass="error"/>
                        </p>
                        <p>                            
                            <h:outputLabel for="patientSex">Patient Sex: </h:outputLabel>
                            <h:selectOneMenu id="patientSex" value="#{patientBean.patientSex}">
                                <f:selectItem itemValue="Male" itemLabel="Male" />
                                <f:selectItem itemValue="Female" itemLabel="Female" />
                            </h:selectOneMenu>
                        </p>
                        <p>                            
                            <h:outputLabel for="patientDateOfBirth">Patient Date Of Birth(yyyy-MM-dd): </h:outputLabel>
                            <h:inputText id="patientDateOfBirth" value="#{patientBean.patientDateOfBirth}" converterMessage="#{msgs.Patient_Date}">
                                <f:convertDateTime pattern="yyyy-MM-dd"/>
                            </h:inputText>
                            <h:message for="patientDateOfBirth" styleClass="error"/>
                        </p>
                        <p>                            
                            <h:outputLabel for="patientJob">Patient Job: </h:outputLabel>
                            <h:inputText id="patientJob" value="#{patientBean.patientJob}"/>
                        </p>
                        <p>                            
                            <h:outputLabel for="patientAddress">Patient Address: </h:outputLabel>
                            <h:inputText id="patientAddress" value="#{patientBean.patientAddress}"/>
                        </p>
                        <p>                            
                            <h:outputLabel for="patientPhoneNumber">Patient Phone Number: </h:outputLabel>
                            <h:inputText id="patientPhoneNumber" value="#{patientBean.patientPhoneNumber}" validatorMessage="#{msgs.Patient_PhoneInvalid}">
                                <f:validateRegex pattern="^[0-9-]{10,12}$"/>
                            </h:inputText>
                            <h:message for="patientPhoneNumber" styleClass="error"/>
                        </p>
                        <p>                            
                            <h:outputLabel for="patientEmail">Patient email: </h:outputLabel>
                            <h:inputText id="patientEmail" value="#{patientBean.patientEmail}"
                                         validatorMessage="#{msgs.Patient_Email}"
                                         >
                                <f:validateRegex pattern="[\w\.-]*[a-zA-Z0-9_]@[\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]"/>                                
                            </h:inputText>
                            <h:message for="patientEmail" styleClass="error"/>
                        </p>
                        <p>                            
                            <h:outputLabel for="patientHeight">Patient Height: </h:outputLabel>
                            <h:inputText id="patientHeight" value="#{patientBean.patientHeight}">
                                <f:convertNumber/>
                            </h:inputText>
                            <h:message for="patientHeight" styleClass="error"/>
                        </p>
                        <p>                            
                            <h:outputLabel for="patientWeight">Patient Weight: </h:outputLabel>
                            <h:inputText id="patientWeight" value="#{patientBean.patientWeight}">
                                <f:convertNumber/>
                            </h:inputText>
                            <h:message for="patientWeight" styleClass="error"/>
                        </p>
                        <p>                            
                            <h:outputLabel for="patientBloodType">Patient Blood Type: </h:outputLabel>
                            <h:inputText id="patientBloodType" value="#{patientBean.patientBloodType}"/>
                        </p>                        
                        <p>
                            <h:inputHidden value="#{patientBean.patientID}" id="patientID" />                        
                            <h:commandButton value="Update" action="#{patientBean.editPatient()}"/>
                        </p>                        
                    </fieldset>
                </h:form>
            </ui:define>
        </ui:composition>
    </h:body>
</html>

